﻿using MySql.Data.MySqlClient;
using NB.MGJ.FrameWork;
using NB.MGJ.Model;
using NB.MGJ.Model.OriginsEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NB.MGJ.Service
{
    public class PaymentService
    {
        public BaseRepository _baseRepository = new BaseRepository();

        /// <summary>
        /// 添加充值账单记录
        /// </summary>
        /// <returns></returns>
        public int AddTradingrecord(organization_PaymentInfo model) 
        {
            return _baseRepository.Insert<organization_PaymentInfo>(model);
        }


        public PagedList<organization_PaymentInfo> GetPaymentInfoTable(ref PagerModel pager)
        {
            StringBuilder strSql1 = new StringBuilder();
            strSql1.Append(@"organization_PaymentInfo");

            var strSql = new StringBuilder(strSql1.ToString().Trim(','));
            pager.FldName = " ID,EnterpriseID,LoginName,DealTime,DealMoney,Dealmoney,IsBill,remark,PeyType,openid,out_trade_no,transaction_id, PayCode   ";
            pager.TblName = strSql.ToString();
            if (string.IsNullOrEmpty(pager.FldSort) || pager.FldSort == "")
                pager.FldSort = "   DealTime desc ";
            MySqlParameter[] parameters = _baseRepository.SqParameterRefactor(ref pager);
            IEnumerable<organization_PaymentInfo> resultList = _baseRepository.ExecuteStoredProcedureCollection<organization_PaymentInfo>("Common_PageList", parameters);
            return new PagedList<organization_PaymentInfo>(resultList, pager.Page, pager.PageSize, 1, Convert.ToInt32(parameters[6].Value));
        }
    }
}
